import { createRouter, createWebHistory } from 'vue-router'
// import HomeView from '../views/HomeView.vue'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            redirect: '/login'
        },
        {
            path: '/login',
            component: () => import('@/views/Login.vue'),
        },
        {
            path: '/layout',
            component: () => import('@/views/Layout.vue'),
            children: [
                {
                    path: '/index',
                    component: () => import('@/views/layout/Index.vue'),
                },
                {
                    path: '/zhengshu',
                    component: () => import('@/views/layout/ZhengShu.vue'),
                    children: [
                        {
                            path: '/zs',
                            component: () => import('@/views/layout/zhengshu/Zs.vue'),
                        },
                        {
                            path: '/zhuanye',
                            component: () => import('@/views/layout/zhengshu/ZhuanYe.vue'),
                        }
                    ]
                },
                {
                    path: '/xinwen',
                    component: () => import('@/views/layout/XinWen.vue'),
                }
            ]
        },
    ],
})

// router.beforeEach((to) => {
//     let token = localStorage.getItem('token')
//     if (!token && to.path !== '/login') return '/login'
//     if (token && to.path === '/login') return '/index'
// })

export default router
